//
//  GLDismissAnimatedTransition.m
//  HGLAnimation
//
//  Created by huang long on 17/3/30.
//  Copyright © 2017年 huang gu long. All rights reserved.
//

#import "GLDismissAnimatedTransition.h"

@implementation GLDismissAnimatedTransition


- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIView *fromView = [fromVC view];
    
    [UIView animateWithDuration:self.duration animations:^{
        fromView.alpha = 0.15;
        fromView.transform = CGAffineTransformMakeScale(0.2, 0.2);
    }completion:^(BOOL finished) {
        //        fromView.transform = CGAffineTransformIdentity;
        [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
    }];
    
    //    [self hideVC:transitionContext];
    
    
}


- (void)hideVC:(id<UIViewControllerContextTransitioning>)transitionContext{
    UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
    [UIView animateWithDuration:self.duration animations:^{
        
        fromView.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);//3D动画
        fromView.alpha = 0;
    } completion:^(BOOL finished) {
        [transitionContext completeTransition:YES];
    }];
}

@end
